#!/bin/sh

FILES=$(find ".hx" . | grep -e ".hx$")

for f in $FILES
do
  sed -i 's/for *each/for/g' $f # Remove 'for each' syntax
  sed -i 's/for *( *var \+\([a-zA-Z]\+\): \?[A-Za-z]\+/for ( \1/g' $f # Remove type cues
  sed -i 's@for \?( \?\([a-z]\+\) \?= \?\([0-9]\+\) \?; \?[a-z]\+ \?< \?\([a-zA-Z\.]\+\); \?[a-z+]\+ \?)@for ( \1 in \2...\3 )@g' $f
  sed -i 's@for \?( \?\([a-z]\+\) \?= \?\([0-9A-Za-z]\+\) \?; \?[a-z]\+ \?<= \?\([a-zA-Z\.]\+\); \?[a-z+]\+ \?)@for ( \1 in \2...(\3+1) )@g' $f
done
